package com.sg.service.base.app.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.dto.base.app.req.*;
import com.sg.entity.OmsQuestion;
import com.sg.service.base.app.MOmsQuestionService;
import com.wicket.okrapp.common.dto.FieldInfo;
import com.wicket.okrapp.common.exception.BizException;
import com.wicket.okrapp.dal.mapper.mbg.OmsQuestionMapper;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author ：
 * @version 1.0
 * @since 2022/1/19 15:39
 */
@Service
public class MOmsQuestionServiceImpl
        extends ServiceImpl<OmsQuestionMapper, OmsQuestion>
        implements MOmsQuestionService {

    @Autowired
    OmsQuestionMapper omsQuestionMapper;

    /**
     * 3-7-02新增问题[7744]
     * gen by moon at 12/7/2023, 11:42:48 PM
     */
    @Trace(operationName = "3-7-02新增问题")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String addQuestion(OmsQuestion omsQuestion) {
        omsQuestion.setQuestionId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
        omsQuestion.setQuestionCode("QUES" + CommonFunctionHelper.getUid());//AUTO_GENERATE
        omsQuestion.setOrderNumber(Long.valueOf(1));//CUSTOM_CONVENTION
        omsQuestion.setRelevantPeopleNum(Long.valueOf(0));//CUSTOM_CONVENTION
        omsQuestion.setIsArchive("FALSE");
        omsQuestion.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsQuestion.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        if (omsQuestion != null && omsQuestion.getSubjectLifeCycle() != null && omsQuestion.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsQuestion.setReleaseInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//RELEASED_CURRENT_INDUCTIONID
        }
        omsQuestion.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsQuestion.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        if (omsQuestion != null && omsQuestion.getSubjectLifeCycle() != null && omsQuestion.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsQuestion.setReleaseTime(CommonFunctionHelper.getCurrentTime());//RELEASE_SYSTEM_CURRENT_TIME
        }
        omsQuestion.setIsValid("FALSE");
        omsQuestion.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
        omsQuestion.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
        if (super.save(omsQuestion)) {
            return omsQuestion.getQuestionId();
        } else {
            return "-1";
        }

    }

    /**
     * 3-7-02修改问题[7745]
     * gen by moon at 11/8/2023, 3:43:53 PM
     */
    @Trace(operationName = "3-7-02修改问题")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateQuestion(OmsQuestion omsQuestion) {
        omsQuestion.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        if (omsQuestion != null && omsQuestion.getSubjectLifeCycle() != null && omsQuestion.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsQuestion.setReleaseInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//RELEASED_CURRENT_INDUCTIONID
        }
        if (omsQuestion != null && omsQuestion.getSubjectLifeCycle() != null && omsQuestion.getSubjectLifeCycle().equals("ARCHIVING")) {
            omsQuestion.setArchiveInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//ARCHIVE_CURRENT_INDUCTIONID
        }
        omsQuestion.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        if (omsQuestion != null && omsQuestion.getSubjectLifeCycle() != null && omsQuestion.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsQuestion.setReleaseTime(CommonFunctionHelper.getCurrentTime());//RELEASE_SYSTEM_CURRENT_TIME
        }
        if (omsQuestion != null && omsQuestion.getSubjectLifeCycle() != null && omsQuestion.getSubjectLifeCycle().equals("ARCHIVING")) {
            omsQuestion.setArchiveTime(CommonFunctionHelper.getCurrentTime());//HISTORICAL_ARCHIVING
        }
        return super.updateById(omsQuestion);
    }

    /**
     * 3-7-02查询问题列表[7752]
     * gen by moon at 12/16/2023, 8:27:48 PM
     */
    @Trace(operationName = "3-7-02查询问题列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsQuestion> queryQuestionList(QueryQuestionListReq reqDto) {

        try {
            QueryWrapper<OmsQuestion> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");

            // TODO: 2024/8/6
            if (reqDto.getCreateTime() != null && reqDto.getReleaseTime() != null) {
                queryWrapper.ge("create_time", reqDto.getCreateTime());
                queryWrapper.le("release_time", reqDto.getReleaseTime());
                reqDto.setCreateTime(null);
                reqDto.setReleaseTime(null);
            }

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsQuestion.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("create_time");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsQuestion>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-02-查询问题详情[7783]
     * gen by moon at 11/8/2023, 3:44:00 PM
     */
    @Trace(operationName = "3-7-02-查询问题详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsQuestion queryQuestionDetail(QueryQuestionDetailReq reqDto) {

        try {
            reqDto.setIsValid("FALSE");
            QueryWrapper<OmsQuestion> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsQuestion> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsQuestion retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-02删除问题[7804]
     * gen by moon at 11/8/2023, 3:44:01 PM
     */
    @Trace(operationName = "3-7-02删除问题")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteQuestion(String questionId) {

        return super.removeById(questionId);
    }

    /**
     * 3-7-02批量查询问题[7812]
     * gen by moon at 12/16/2023, 8:27:48 PM
     */
    @Trace(operationName = "3-7-02批量查询问题")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsQuestion> batchQueryQuestion(BatchQueryQuestionReq reqDto) {

        try {
            QueryWrapper<OmsQuestion> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            if (reqDto.getQuestionList() == null || reqDto.getQuestionList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("question_id", reqDto.getQuestionList());

            // TODO: 2023/11/15手写代码
            if (reqDto.getCreateTime() != null) {
                queryWrapper.ge("create_time", reqDto.getCreateTime());
                reqDto.setCreateTime(null);
            }

            // TODO: 2024/8/6  
            if (reqDto.getReleaseTime() != null) {
                queryWrapper.le("release_time", reqDto.getReleaseTime());
                reqDto.setReleaseTime(null);
            }
            // TODO: 2024/1/22
            if (reqDto.getQuestionIntroduce() != null) {
                queryWrapper.like("question_introduce", reqDto.getQuestionIntroduce());
                reqDto.setQuestionIntroduce(null);
            }
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsQuestion.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("create_time");
            queryWrapper.orderByDesc("operate_time");

            return ((List<OmsQuestion>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-02执行归属对象批量查问题[7988]
     * gen by moon at 11/20/2023, 2:14:34 PM
     */
    @Trace(operationName = "3-7-02执行归属对象批量查问题")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsQuestion> implementCoordObjecBatchQueryQuestion(ImplementCoordObjecBatchQueryQuestionReq reqDto) {

        try {
            QueryWrapper<OmsQuestion> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            if (reqDto.getQuestionList() == null || reqDto.getQuestionList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("coord_object_id", reqDto.getQuestionList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsQuestion.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsQuestion>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-02执行模糊查问题列表[8156]
     * gen by moon at 12/17/2023, 2:58:16 PM
     */
    @Trace(operationName = "3-7-02执行模糊查问题列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsQuestion> queryBlurQueryQuestionList(QueryBlurQueryQuestionListReq reqDto) {

        try {
            QueryWrapper<OmsQuestion> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");

            if (reqDto.getCreateTime() != null) {
                queryWrapper.ge("create_time", reqDto.getCreateTime());
                reqDto.setCreateTime(null);
            }

            // TODO: 2024/1/22
            if (reqDto.getQuestionIntroduce() != null) {
                queryWrapper.like("question_introduce", reqDto.getQuestionIntroduce());
                reqDto.setQuestionIntroduce(null);
            }

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsQuestion.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("create_time");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsQuestion>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-02批量查询问题By归属对象ID[8931]
     * gen by moon at 3/31/2024, 1:45:25 AM
     */
    @Trace(operationName = "3-7-02批量查询问题By归属对象ID")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsQuestion> batchQueryProblem(BatchQueryProblemReq reqDto) {

        try {
            QueryWrapper<OmsQuestion> queryWrapper = new QueryWrapper<>();

            if (reqDto.getQuestionList() == null || reqDto.getQuestionList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("coord_object_id", reqDto.getQuestionList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsQuestion.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsQuestion>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-02批量查询问题解决天数排行[9004]
     * gen by moon at 4/1/2024, 12:12:25 AM
     */
    @Trace(operationName = "3-7-02批量查询问题解决天数排行")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsQuestion> batchQueryQuestionSolvesRank(BatchQueryQuestionSolvesRankReq reqDto) {

        try {
            QueryWrapper<OmsQuestion> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            if (reqDto.getQuestionList() == null || reqDto.getQuestionList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("question_id", reqDto.getQuestionList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsQuestion.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("actual_solve_cycle");
            queryWrapper.orderByDesc("question_level");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsQuestion>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-02批量查询问题超时排行[9006]
     * gen by moon at 4/1/2024, 12:12:29 AM
     */
    @Trace(operationName = "3-7-02批量查询问题超时排行")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsQuestion> batchQueryQuestionTimeoutRank(BatchQueryQuestionTimeoutRankReq reqDto) {

        try {
            QueryWrapper<OmsQuestion> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            if (reqDto.getQuestionList() == null || reqDto.getQuestionList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("question_id", reqDto.getQuestionList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsQuestion.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("over_time_length");
            queryWrapper.orderByAsc("create_time");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsQuestion>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-02查询问题超时排行列表[9079]
     * gen by moon at 4/2/2024, 6:13:13 PM
     */
    @Trace(operationName = "3-7-02查询问题超时排行列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsQuestion> queryQuestionTimeoutRankList(QueryQuestionTimeoutRankListReq reqDto) {

        try {
            QueryWrapper<OmsQuestion> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("TRUE");

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsQuestion.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("over_time_length");
            queryWrapper.orderByAsc("create_time");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsQuestion>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-02查询问题解决天数排行列表[9080]
     * gen by moon at 4/2/2024, 6:13:14 PM
     */
    @Trace(operationName = "3-7-02查询问题解决天数排行列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsQuestion> queryQuestionSolvesRankList(QueryQuestionSolvesRankListReq reqDto) {

        try {
            QueryWrapper<OmsQuestion> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsQuestion.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsQuestion.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("actual_solve_cycle");
            queryWrapper.orderByDesc("question_level");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsQuestion>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }
}
